package org.quipu.api;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import org.quipu.AppException;
import org.quipu.dto.AccountDto;
import org.quipu.dto.BookDto;
import org.quipu.dto.CurrencyDto;
import org.quipu.dto.TransactionDto;
import org.quipu.dto.AccountDetailDto;
import org.quipu.dto.BookCacheDto;
import org.quipu.dto.BookUserDto;
import org.quipu.dto.CategoryDto;
import org.quipu.dto.TagDto;
import org.quipu.dto.TransactionsFilterDto;

@Local
public interface BookHelper {

    public Map<String, String> getSettings(String username) throws AppException;

    public void submitBook(BookDto book, Long userId) throws AppException;
    public void removeBook(Long bookId) throws AppException;
    public BookCacheDto getBookCache(Long bookId, Long userId) throws AppException;

    public void createOrUpdateCurrency(CurrencyDto currencyDto) throws AppException;
    public void removeCurrency(Long currencyId) throws AppException;

    public void submitTag(TagDto tagDto) throws AppException;
    public void removeTag(Long tagId) throws AppException;

    public void createOrUpdateCategory(CategoryDto categoryDto) throws AppException;
    public void removeCategory(Long categoryId) throws AppException;

    public void createOrUpdateAccount(AccountDto accountDto) throws AppException;
    public void removeAccount(Long accountId) throws AppException;

    public void submitTransaction(TransactionDto transactionDto) throws AppException;
    public void detachTransaction(TransactionDto transaction, Long originalId) throws AppException;
    public void removeTransaction(Long transactionId) throws AppException;
    public List<TransactionDto> findTransactions(Long bookId, TransactionsFilterDto filter, int page, int pageSize) throws AppException;

    public Double getInitialBalance(Long accountId, Long currencyId, Date date);
    public List<BookDto> getUserBooks(String login) throws AppException;
    public List<BookDto> getUserBooks(Long userId) throws AppException;
    public BookUserDto getBookUserDto(Long bookId, Long userId) throws AppException;
    public List<CurrencyDto> getBookCurrencies(Long bookId) throws AppException;
    public List<TagDto> getBookTags(Long bookId) throws AppException;
    public List<CategoryDto> getBookCategoriesTree(Long bookId, CategoryDto.Type type) throws AppException;
    public List<AccountDto> getBookAccounts(Long bookId) throws AppException;
    public List<AccountDetailDto> getBookAccountsCalculation(Long bookId, Date date, boolean approvedOnly) throws AppException;
    public List<Map<Long, Double[]>> getBalanceArchive(Long bookId, Date dateFrom, Date dateTo, boolean approvedOnly) throws AppException;

    public Double getInitialBallanceSum(Collection<Long> accountIds, Long currencyId, Date date);
}
